package com.shawn.baseappbygroovydsl.ui.views

import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import com.app.hubert.guide.NewbieGuide
import com.app.hubert.guide.model.GuidePage
import com.shawn.baseappbygroovydsl.R
import com.shawn.baseappbygroovydsl.databinding.FragmentSecondBinding
import com.shawn.baseappbygroovydsl.ui.base.FragmentBase
import com.shawn.baseappbygroovydsl.ui.extension.ExtensionCommon.appToastV2

class SecondFragment  : FragmentBase<FragmentSecondBinding>(R.layout.fragment_second) {



    companion object {
        fun newInstance(): SecondFragment {
            val args = Bundle()
            val fragment = SecondFragment()
            fragment.arguments = args
            return fragment
        }
    }

    override fun onKeyCodeBack(): Boolean {
        return false
    }

    override fun statusBar() {

    }

    override fun lazyLoad() {
        mBind.btn1.postDelayed({
                     mBind.highlightView.startHighlight(mBind.textSlideshow)
        },1000)
    }

    override fun initClick() {
        mBind.btnClose.setOnClickListener {
            removeSubFragBySelf(this)
        }
        mBind.btn1.setOnClickListener {

        }
        mBind.highlightView.setOnClickListener {
            removeSubFragBySelf(this)
        }
    }

    override fun getData() {
    }

    override fun getBind(view: View): FragmentSecondBinding {
        return FragmentSecondBinding.bind(view)
    }

    private fun showGuideView1(targetView: View?) {
        activity?.let {
            NewbieGuide.with(activity).setLabel("guide1").alwaysShow(true)
                .addGuidePage(
                    GuidePage.newInstance().addHighLight(targetView)
                    .setLayoutRes(R.layout.guide_1).setEverywhereCancelable(true)
                    .setOnLayoutInflatedListener { view1, controller ->
                        if (view1 == null) {
                            controller.remove()
                        } else {
                            view1.findViewById<ViewGroup>(R.id.root).setOnClickListener {
                                "引导页被点击".appToastV2(activity)
                                controller.remove()
                            }
                        }
                    }).show()
        }
    }
}